# -*- mode: CMake -*- 
#--------------------------------------------------------------------------------#
# Package File for aliroot                                                       #
# Author : Johny Jose (johny.jose@cern.ch)                                       #
# Variables Defined :                                                            #
#                                                                                #
# SRCS - C++ source files                                                        #
# HDRS - C++ header files                                                        #
# DHDR - ROOT Dictionary Linkdef header file                                     #
# CSRCS - C source files                                                         #
# CHDRS - C header files                                                         #
# EINCLUDE - Include directories                                                 #
# EDEFINE - Compiler definitions                                                 #
# ELIBS - Extra libraries to link                                                #
# ELIBSDIR - Extra library directories                                           #
# PACKFFLAGS - Fortran compiler flags for package                                #
# PACKCXXFLAGS - C++ compiler flags for package                                  #
# PACKCFLAGS - C compiler flags for package                                      #
# PACKSOFLAGS - Shared library linking flags                                     #
# PACKLDFLAGS - Module linker flags                                              #
# PACKBLIBS - Libraries to link (Executables only)                               #
# EXPORT - Header files to be exported                                           #
# CINTHDRS - Dictionary header files                                             #
# CINTAUTOLINK - Set automatic dictionary generation                             #
# ARLIBS - Archive Libraries and objects for linking (Executables only)          #
# SHLIBS - Shared Libraries and objects for linking (Executables only)           #
#--------------------------------------------------------------------------------#

set ( SRCS aliroot.cxx)
set ( CSRCS fpu.c)

set ( ELIBSDIR )

set(MFT_UPGRADE $ENV{MFT_UPGRADE})
  
if(MFT_UPGRADE)
set ( ELIBS  MUONevaluation 	MUONmapping MUONshuttle MUONgraphics MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw MUONtrigger MUONcore TPCbase TPCsim TPCrec TPCfast ITSbase ITSsim ITSrec PMDbase PMDsim PMDrec TRDbase TRDsim TRDrec FMDbase FMDsim FMDrec TOFbase TOFrec TOFsim PHOSUtils PHOSbase PHOSsim PHOSrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDrec HMPIDsim ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec MFTbase MFTsim MFTrec EMCALUtils EMCALbase EMCALsim EMCALrec EMCALraw BCM STRUCT T0base T0sim T0rec FASTSIM microcern HLTbase TRIGGERbase STEER STAT CDB AOD  STEERBase ESD ANALYSIS RAWDatasim RAWDatarec RAWDatabase XGLUtils)
else(MFT_UPGRADE)
set ( ELIBS  MUONevaluation 	MUONmapping MUONshuttle MUONgraphics MUONsim MUONrec MUONgeometry MUONcalib MUONbase MUONraw MUONtrigger MUONcore TPCbase TPCsim TPCrec TPCfast ITSbase ITSsim ITSrec PMDbase PMDsim PMDrec TRDbase TRDsim TRDrec FMDbase FMDsim FMDrec TOFbase TOFrec TOFsim PHOSUtils PHOSbase PHOSsim PHOSrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDrec HMPIDsim ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec EMCALUtils EMCALbase EMCALsim EMCALrec EMCALraw BCM STRUCT T0base T0sim T0rec FASTSIM microcern HLTbase TRIGGERbase STEER STAT CDB AOD  STEERBase ESD ANALYSIS RAWDatasim RAWDatarec RAWDatabase XGLUtils)
endif(MFT_UPGRADE)

if(PYTHIA6)
  list(APPEND ELIBS EVGEN)
endif(PYTHIA6)

if( ALICE_TARGET STREQUAL "macosx")
		
  string(REGEX REPLACE "(microcern|lhapdf|herwig)" "" ELIBS "${ELIBS}") 
  
  ALICE_Format(PACKLDFLAGS "-Wl,-u,_G__cpp_setupG__" "" "${LDFLAGS};${ELIBSCPP}")
  string ( REPLACE "%" "-Wl,-u,_G__cpp_setupG__%" PACKLDFLAGS "${LDFLAGS} ${ELIBSCPP}" )
		
	set ( ELIBSDIR ${ELIBSDIR} ${FINK_ROOT}/lib)

endif( ALICE_TARGET STREQUAL "macosx")

if(MFT_UPGRADE)
  set (ARPACKS FMDbase FMDsim FMDrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDsim HMPIDrec ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec MFTbase MFTsim MFTrec EMCALUtils EMCALbase EMCALsim EMCALrec T0base T0sim T0rec TOFbase TOFsim TOFrec TRDbase TRDsim TRDrec PMDbase PMDsim PMDrec MUONmapping MUONmapping MUONgeometry MUONbase MUONsim MUONrec MUONraw PHOSUtils PHOSbase PHOSsim PHOSrec HLTbase ITSbase ITSsim ITSrec STRUCT TPCbase TPCsim TPCrec TPCfast STEER CDB ESD STEERBase RAWDatabase RAWDatasim RAWDatarec MDC TRIGGERbase XGLUtils)
else(MFT_UPGRADE)
  set (ARPACKS FMDbase FMDsim FMDrec ACORDEbase ACORDEsim ACORDErec HMPIDbase HMPIDsim HMPIDrec ZDCbase ZDCsim ZDCrec VZERObase VZEROsim VZEROrec EMCALUtils EMCALbase EMCALsim EMCALrec T0base T0sim T0rec TOFbase TOFsim TOFrec TRDbase TRDsim TRDrec PMDbase PMDsim PMDrec MUONmapping MUONmapping MUONgeometry MUONbase MUONsim MUONrec MUONraw PHOSUtils PHOSbase PHOSsim PHOSrec HLTbase ITSbase ITSsim ITSrec STRUCT TPCbase TPCsim TPCrec TPCfast STEER CDB ESD STEERBase RAWDatabase RAWDatasim RAWDatarec MDC TRIGGERbase XGLUtils)
endif(MFT_UPGRADE)

set(GFILES)
foreach (pkg ${ARPACKS})
#  foreach(mod ${MODDIRS})
#    string(REGEX MATCH "${mod}" DIR ${pkg})
#    if(DIR)
#      list(APPEND GFILES "${CMAKE_BINARY_DIR}/${DIR}/CMakeFiles/${pkg}_a.dir/G__${pkg}.cxx.o" )
#      set_source_files_properties("G${pkg}" PROPERTIES GENERATED TRUE )
#      set_source_files_properties("G__${pkg}.cxx" PROPERTIES GENERATED TRUE)
      list(APPEND AFILES "${pkg}_a")

#    endif(DIR)
#  endforeach(mod) 
endforeach(pkg)
set (ARLIBS ${AFILES})
list(APPEND SRCS ${GFILES})
set ( SHLIBS  ${BINLIBDIRS} EVGEN -lEGPythia6 Pythia6 -lpythia6 AliPythia6 lhapdf THijing hijing THerwig herwig TPHIC FASTSIM microcern)

set ( EINCLUDE STEER/STEER )
